package com.huabo.contract.service.impl;

import com.hbfk.util.PageInfo;
import com.huabo.contract.config.DateBaseConfig;
import com.huabo.contract.oracle.entity.TblLegalArbitrationrecord;
import com.huabo.contract.oracle.mapper.TblLegalArbitrationrecordMapper;
import com.huabo.contract.service.TblLegalArbitrationrecordService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class TblLegalArbitrationrecordServiceImpl implements TblLegalArbitrationrecordService {


    @Resource
    private TblLegalArbitrationrecordMapper tblLegalArbitrationrecordMapper;

    @Override
    public List<TblLegalArbitrationrecord> findListBynegotiaId(Integer arbitraId) {
        if(DateBaseConfig.DATABASETYPE.equals("Oracle")) {
            return tblLegalArbitrationrecordMapper.findListBynegotiaId(arbitraId);
        } else {
            return tblLegalArbitrationrecordMapper.findListBynegotiaId(arbitraId);
        }
    }

    @Override
    public void saveNegotiateRecord(TblLegalArbitrationrecord record) {
        if(DateBaseConfig.DATABASETYPE.equals("Oracle")) {
            this.tblLegalArbitrationrecordMapper.saveNegotiateRecord(record);
        } else {
            this.tblLegalArbitrationrecordMapper.saveNegotiateRecord(record);
        }
    }

    @Override
    public TblLegalArbitrationrecord findById(Integer arrecordId) {
        if(DateBaseConfig.DATABASETYPE.equals("Oracle")) {
            return tblLegalArbitrationrecordMapper.findByArrecordId(arrecordId);
        } else {
            return tblLegalArbitrationrecordMapper.findByArrecordId(arrecordId);
        }
    }

    @Override
    public void modifyNegotiateRecord(TblLegalArbitrationrecord oldRecord) {
        if(DateBaseConfig.DATABASETYPE.equals("Oracle")) {
            tblLegalArbitrationrecordMapper.modifyNegotiateRecord(oldRecord);
        } else {
            tblLegalArbitrationrecordMapper.modifyNegotiateRecord(oldRecord);
        }
    }

    @Override
    public void removeNegitiateRecord(Integer arrecordId) {
        if(DateBaseConfig.DATABASETYPE.equals("Oracle")) {
            tblLegalArbitrationrecordMapper.removeNegitiateRecord(arrecordId);
        } else {
            tblLegalArbitrationrecordMapper.removeNegitiateRecord(arrecordId);
        }
    }

    @Override
    public void findListByPageInfo(PageInfo<TblLegalArbitrationrecord> pageInfo, Integer arrecordid) {
        if(DateBaseConfig.DATABASETYPE.equals("Oracle")) {
            Map<String, Object> resultMap = new HashMap<String, Object>(0);
            pageInfo.setTlist(tblLegalArbitrationrecordMapper.findListByPageInfo(pageInfo, arrecordid));
            pageInfo.setTotalRecord(tblLegalArbitrationrecordMapper.findListByPageInfoCount(arrecordid));
            resultMap.put("code", "1");
            resultMap.put("msg", "访问接口成功");
            resultMap.put("data", pageInfo);
        } else {
            Map<String, Object> resultMap = new HashMap<String, Object>(0);
            pageInfo.setTlist(tblLegalArbitrationrecordMapper.findListByPageInfo(pageInfo, arrecordid));
            pageInfo.setTotalRecord(tblLegalArbitrationrecordMapper.findListByPageInfoCount(arrecordid));
            resultMap.put("code", "1");
            resultMap.put("msg", "访问接口成功");
            resultMap.put("data", pageInfo);
        }
    }
}
